import React from 'react';
import { DnFC } from '@inbiz/react';
import { createBehavior, createResource } from '@inbiz/core';
import Content from '../../preview/wap/index';
import { Message as LocaleMessage } from '../locale';
import { propsH5Schema, defaultH5Props, defaultH5BizProps } from '../schema';

const Message: DnFC<React.ComponentProps<typeof Content>> = Content;

Message.Behavior = createBehavior({
  extends: ['Field'],
  name: 'Message',
  selector: (node: any) => node?.props['x-component'] === 'Message',
  designerLocales: LocaleMessage,
  designerProps: {
    propsSchema: propsH5Schema,
  },
});

Message.Resource = createResource({
  icon: 'Message',
  elements: [
    {
      componentName: 'Field',
      props: {
        type: 'void',
        'x-decorator': 'Container',
        'x-decorator-props': {
          clickable: false,
        },
        title: {
          status: true,
          value: 'Message.title',
        },
        'x-component': 'Message',
        'x-component-biz-props': defaultH5BizProps,
        'x-component-props': defaultH5Props,
      },
    },
  ],
});

export default Message